package com.example.qa.service.application.service;

import com.example.qa.service.application.command.CreateQaCommand;
import com.example.qa.service.application.port.in.CreateQaCase;
import com.example.qa.service.domain.Qa;
import com.example.qa.service.domain.port.CreateQaPort;
import com.example.qa.service.domain.valueobject.Answer;
import com.example.qa.service.domain.valueobject.Question;


import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class CreateQaService implements CreateQaCase {
    @Resource
    private CreateQaPort createQaPort;
    @Override
    public Qa createQa(CreateQaCommand createQaCommand) {
        Qa qa = new Qa(
                new Question(createQaCommand.question()),
                new Answer(createQaCommand.answer())
        );
        log.info("question:{}",qa.getQuestion());
        return createQaPort.createQa(qa);
    }
}
